<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<head>
</head>
<body>
	<div id="proxycity">
		<table class='tableSiz1'>
			<tr>
				<td><select id="province" style="width:120px;"></select></td>
				<td><select id="city" style="width:120px;"></select></td>
				<td><select id="area" style="width:120px;"></select></td>
				<td><select id="street" style="width:120px;"></select></td>
			</tr>
		</table>
	</div>



<script type="text/javascript">
	var cityId=-1;
	initSel("province");
	loaddata(0);
	initSel("city");initSel("area");initSel("street");

	$("#province").change(function(){loaddata(1);});
	$("#city").change(function(){loaddata(2);});
	$("#area").change(function(){loaddata(3);});
	$("#street").change(function(){loaddata(4);});
	function loaddata(t){
		var cname;
		var fun=function(data){
			if(1==data.s){
				var i=0;
				for (var index in data.cmap) {
					i++;
					$("#"+cname+"").append("<option value='"+index+"'>"+data.cmap[index]+"</option>");
				};
				if(i<=0){
					nullSel(t);
				}
			}else{
				nullSel(t);
			}
		};
		if(0==t){
			cname="province";
			exeAjax(ajaxUrl("${aier_url}commonjs/loadCity${aier_suffix}"),fun, {"cityId":cityId});
		}else if(1==t){
			cname="city";
			cityId=$("#province").val();
			initSel("city");
			exeAjax(ajaxUrl("${aier_url}commonjs/loadCity${aier_suffix}"),fun, {"cityId":cityId});
		}else if(2==t){
			cname="area";
			cityId=$("#city").val();
			initSel("area");
			exeAjax(ajaxUrl("${aier_url}commonjs/loadCity${aier_suffix}"),fun, {"cityId":cityId});
		}else if(3==t){
			cname="street";
			cityId=$("#area").val();
			initSel("street");
			exeAjax(ajaxUrl("${aier_url}commonjs/loadCity${aier_suffix}"),fun, {"cityId":cityId});
		}else if(4==t){
			cityId=$("#street").val();
		}
	}
	
	function initSel(id,name){
		if(undefined==name||null==name){name="请选择";}
		$("#"+id+"").find('option').remove().end().append('<option value="-1">'+name+'</option>');
	}
	
	function nullSel(t){
		switch(t){
		case 0:
			initSel("province","无数据");
		case 1:
			initSel("city","无数据");
		case 2:
			initSel("area","无数据");
		case 3:
			initSel("street","无数据");
		}
	}
</script>
</body>
</html>